Telegram Group & Telegram Channel
🧠 Задача на Go (1.22+)


package main

import "fmt"

func main() {
m = map[string]int{"a": 1, "b": 2, "c": 3}

defer fmt.Println("done")

for k, v := range m {
defer fmt.Println(k, v)
}
}


Что выведет этот код?

A.
c 3
b 2
a 1
done

B.
done
a 1
b 2
c 3

C.
done
c 3
b 2
a 1

D.
a 3
a 3
a 3
done

Почему A? — в Go 1.22 range-переменные k и v создаются на каждом шаге заново, а defer захватывает копии, не ссылки.



tg-me.com/golangtests/770
Create:
Last Update:

🧠 Задача на Go (1.22+)


package main

import "fmt"

func main() {
m = map[string]int{"a": 1, "b": 2, "c": 3}

defer fmt.Println("done")

for k, v := range m {
defer fmt.Println(k, v)
}
}


Что выведет этот код?

A.
c 3
b 2
a 1
done

B.
done
a 1
b 2
c 3

C.
done
c 3
b 2
a 1

D.
a 3
a 3
a 3
done

Почему A? — в Go 1.22 range-переменные k и v создаются на каждом шаге заново, а defer захватывает копии, не ссылки.

BY Go tests


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/golangtests/770

View MORE
Open in Telegram


Go tests Telegram | DID YOU KNOW?

Date: |

Can I mute a Telegram group?

In recent times, Telegram has gained a lot of popularity because of the controversy over WhatsApp’s new privacy policy. In January 2021, Telegram was the most downloaded app worldwide and crossed 500 million monthly active users. And with so many active users on the app, people might get messages in bulk from a group or a channel that can be a little irritating. So to get rid of the same, you can mute groups, chats, and channels on Telegram just like WhatsApp. You can mute notifications for one hour, eight hours, or two days, or you can disable notifications forever.

Telegram is riding high, adding tens of million of users this year. Now the bill is coming due.Telegram is one of the few significant social-media challengers to Facebook Inc., FB -1.90% on a trajectory toward one billion users active each month by the end of 2022, up from roughly 550 million today.

Go tests from kr


Telegram Go tests
FROM USA